package com.taxsystem.likaifan.taxcompute;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.main.taxsystem.R;
import com.taxsystem.main.MainTabActivity;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

@SuppressLint("NewApi") public class TaxComputeMain extends Activity
{

	final int MY_NOTICE = 0x111;
	final int NAV_SETTING = 0x112;
	final int ACCOUNT_SETTING = 0x113;
	final int INDIVIDUAL_SETTING = 0x114;
	private static final String[] itemText = {"二手房计算","个人所得税计算","车船税计算"};

	
	@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		 
        ActionBar bar = getActionBar();
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.actionbar_icon);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setBackgroundDrawable(new ColorDrawable(0xff333333));     
		
		setContentView(R.layout.grid_view);
	      List<Map<String, Object>> items = new ArrayList<Map<String,Object>>();

	        for (int i = 0; i < 3; i++) {

	          Map<String, Object> item = new HashMap<String, Object>();

	          item.put("imageItem", R.drawable.temp_logo);

	          item.put("textItem", itemText[i]);

	          items.add(item);

	        }

	        SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.grid_item, new String[]{"imageItem", "textItem"}, new int[]{R.id.image_item, R.id.text_item});
	        GridView gridview = (GridView)findViewById(R.id.mygridview);
	        gridview.setAdapter(adapter);

	        gridview.setOnItemClickListener(new OnItemClickListener()
			{
				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id)
				{
					switch ((int)id)
					{
						case 0:
							Intent intent0 = new Intent(TaxComputeMain.this, SecondHandHouseCompute.class);
							startActivity(intent0);
							break;
						case 1:
							Intent intent1 = new Intent(TaxComputeMain.this, IndividualIncomeTaxCompute.class);
							startActivity(intent1);
							break;
						case 2:
							Intent intent2 = new Intent(TaxComputeMain.this, VehicleTaxCompute.class);
							startActivity(intent2);
							break;	

					}

				}

			});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.activity_mian, menu);
		menu.add(0, MY_NOTICE, 0, "我的通知");
		menu.add(0, NAV_SETTING, 0, "导航设置");
		menu.add(0, ACCOUNT_SETTING, 0, "账号设置");
		menu.add(0, INDIVIDUAL_SETTING, 0, "个性化设置");
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem mi)
	{
		
		
		//判断单击的是哪个菜单项，并针对性的作出响应。
		switch (mi.getItemId())
		{
		case android.R.id.home:
			this.finish();
			break;
			case MY_NOTICE:
				Log.d("hehe","heh");
				Toast toast1 = Toast.makeText(getApplicationContext(),
					     "MY_NOTICE", Toast.LENGTH_SHORT);
				toast1.show();
				break;
			case NAV_SETTING:
				Toast toast2 = Toast.makeText(getApplicationContext(),
					     "NAV_SETTING", Toast.LENGTH_SHORT);
				toast2.show();;
				break;
			case ACCOUNT_SETTING:
				Toast toast3 = Toast.makeText(getApplicationContext(),
					     "ACCOUNT_SETTING", Toast.LENGTH_SHORT);
				toast3.show();
				break;
			case INDIVIDUAL_SETTING:
				Toast toast4 = Toast.makeText(getApplicationContext(),
					     "INDIVIDUAL_SETTING", Toast.LENGTH_SHORT);
				toast4.show();
				break;

		}
		return true;
	}
}
